import random

def guess(_maxnumber, _money):
    realnumber = random.randint(1, _maxnumber)
    money = _money
    guessnumber = input(f"请你猜一个1-{_maxnumber}之间的整数:\n")

    while money >= 0:
        if int(guessnumber) == realnumber:
            money += 3000
            print("恭喜你，猜对了!奖励3000金币，当前金币: " + str(money))
            if input("请问是否继续下一轮游戏(输入1进行下一轮游戏)") == '1':
                guess(_maxnumber * 10, money)
            break
        elif int(guessnumber) > realnumber:
            if money > 500:
                money -= 500
                guessnumber = input("对不起猜错了，你猜的数字偏大,惩罚500金币,当前金币: " + str(money) + "\n请重新猜测:\n")
            else:
                print("游戏结束！你失败了,当前金币不足: " + str(money))
                exit()
        else:
            if money > 500:
                money -= 500
                guessnumber = input("对不起猜错了，你猜的数字偏小,惩罚500金币,当前金币: " + str(money) + "\n请重新猜测:\n")
            else:
                print("游戏结束！你失败了,当前金币不足: " + str(money))
                exit()
    if money <= 0:
        print("游戏结束！你失败了,当前金币: " + str(money))


# 开始游戏
guess(10, 2300)
